const { Axios } = require('axios')
const Contants = require('../contants')

const instance = new Axios({
    baseURL: Contants.baseUrl
})

instance.interceptors.response.use(
    config => {
        if (config.headers['content-type'] && config.headers['content-type'].includes('application/json')) {
            const data = JSON.parse(config.data)
            return data 
        }
        return config.data
    },
    err => {
        return Promise.reject(err)
    },
)

module.exports = instance